// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "SnakeGameModeBase.generated.h"

class ARock;
class AFood;
class ASpecialFood;
/**
 * 
 */
UCLASS()
class TASK35_4_API ASnakeGameModeBase : public AGameModeBase
{
	GENERATED_BODY()

public:
	ASnakeGameModeBase();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<ARock> RockClass;

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<AFood> FoodClass;

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<ASpecialFood> SpecialFoodClass;

	UPROPERTY()
	float ElementSize;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
	uint8 MapSize;

	UPROPERTY()
	uint32 GameStage;

	UPROPERTY()
	ASpecialFood* SpeedupBonusItem;

	UPROPERTY()
	TArray<FVector2D> Rocks;

	UPROPERTY(BlueprintReadOnly)
	bool IsDead;

	UPROPERTY()
	FVector2D FoodLocation;

public:
	UFUNCTION()
	float GetElementSize();

	UFUNCTION()
	void GenerateFood(FVector Location);

	UFUNCTION()
	void GenerateSpecialFood(FVector Location);

	UFUNCTION()
	void GenerateRock(FVector Location);

	UFUNCTION()
	void NextStage();

	UFUNCTION()
	void FixDeath();

	UFUNCTION()
	FVector2D GetFreeCell(FVector2D LastFoodLocation, FVector2D SnakeHeadLocation);

	UFUNCTION()
	FVector GetCoordinates(FVector2D Location);
	
};
